package com.bpf.base.service.system;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.bpf.base.util.MapUtil;
import com.bpf.base.dao.system.TSysOperateLogDao;
import com.bpf.base.model.system.TSysOperateLog;

/**
 * TODO 本代码由代码生成工具生成
 * @date 2016-07-19 05:31:26
 */
@Service
public class TSysOperateLogService{

	private Logger logger = LoggerFactory.getLogger(TSysOperateLogService.class);
     
    @Resource
	private TSysOperateLogDao tSysOperateLogDao;
	
	//根据条件搜索记录
	public Map<String , Object> getTSysOperateLogList(Map<String, Object> params){
		Map<String , Object> queryMap = new HashMap<String, Object>();
		Map<String , Object> resultMap = new HashMap<String, Object>();
		//TODO 根据需要封装查询需要的条件
		queryMap.putAll(params);
		resultMap.put("rows", tSysOperateLogDao.selectList(queryMap));
		resultMap.put("total", tSysOperateLogDao.selectCount(queryMap));
		return resultMap;
	}
       
	//新增记录
	public int addTSysOperateLog(Map<String, Object> params){
		try {
			//TODO 根据需要封装查询需要的条件
			TSysOperateLog temp=MapUtil.toObject(TSysOperateLog.class, params);
			return tSysOperateLogDao.insert(temp);
		} catch (Exception e) {
			logger.error("添加失败",e);
			return -1;
		}
	}
	
	//更新记录
	public int updateTSysOperateLog(TSysOperateLog tSysOperateLog){
		return tSysOperateLogDao.update(tSysOperateLog);
	}
	
	//删除记录
	public int delTSysOperateLog(Map<String, Object> params){
		return tSysOperateLogDao.deleteByMap(params);
	}
	
	//根据主键批量删除
	public int delTSysOperateLogBat(String[] idArray){
		for(String pk:idArray){
			tSysOperateLogDao.deleteByPk(pk);
		}
		return idArray.length;
	}
	
	public List<TSysOperateLog> getAllTSysOperateLog(Map<String, Object> params){
		return tSysOperateLogDao.selectList(params);
	}
	
}
